package myzzyl.controller;



import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import myzzyl.domain.dto.RoomDto;
import myzzyl.domain.dto.RoomTypeDto;
import myzzyl.domain.pojo.Room;
import myzzyl.domain.vo.RoomTypeVo;
import myzzyl.domain.vo.RoomVo;
import myzzyl.response.BaseResponse;
import myzzyl.service.RoomService;
import myzzyl.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/room")
@Tag(name = "房间相关")
@Slf4j
public class RoomController {

    @Autowired
    private RoomService roomService;

    /**
     * 获取楼层下所有房间
     */
    @GetMapping("/getRoomsByFloorId/{floorId}")
    public BaseResponse<List<RoomVo>> getAllByFloorId(@PathVariable Long floorId) {
        log.info("获取楼层下所有房间:{}", floorId);
        List<RoomVo> roomVoList = roomService.getAllByFloorId(floorId);
        return BaseResponse.success(roomVoList);
    }

    /**
     * 获取房间详情
     */
    @GetMapping("/get/{id}")
    public BaseResponse<RoomVo> getInfo(@PathVariable Long id) {
        log.info("获取房间详情:{}", id);
        return BaseResponse.success(roomService.getInfo(id));
    }


    /**
     * 新增房间
     */
    @PostMapping("/add")
    public BaseResponse<Boolean> add(@RequestBody RoomDto roomDto) {
        log.info("新增房间:{}", roomDto);
        return BaseResponse.success(roomService.add(roomDto));
    }


    /**
     * 编辑房间
     */
    @PutMapping("/update")
    public BaseResponse<Boolean> edit(@RequestBody RoomDto roomDto) {
        log.info("编辑房间:{}", roomDto);
        return BaseResponse.success(roomService.edit(roomDto));
    }

    /**
     * 删除房间
     */
    @DeleteMapping("/delete/{id}")
    public BaseResponse<Boolean> remove(@PathVariable Long id) {
        log.info("删除房间:{}", id);
        return BaseResponse.success(roomService.deleteRoomById(id));
    }


}
